home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / utils / movevbr / vbr.asm < prev    next >
Encoding:
Assembly Source File  |  1980-01-04  |  2.5 KB  |  134 lines

  1.         include    gst:os3_gst.i
  2.     
  3. VBR_SIZE    = $400            ; size of vector base area in bytes
  4.  
  5. Begin:        move.l    (4).w,a6
  6.         lea    DosName(pc),a1
  7.         moveq    #37,d0
  8.         jsr    _LVOOldOpenLibrary(a6)     ; open dos.library (OS2.04)
  9.         tst.l    d0
  10.         beq.w    error
  11.  
  12.         move.l    d0,a4            ; a4 DOSBase
  13.         moveq    #0,d6            ; d6 Quiet-Flag
  14.         moveq    #0,d7            ; d7 VBR-Flag (1=Zero, -1=Fast)
  15.         exg    a4,a6
  16.         lea    cmd_template(pc),a0
  17.         move.l    a0,d1
  18.         clr.l    -(sp)
  19.         clr.l    -(sp)
  20.         clr.l    -(sp)
  21.         move.l    sp,d2
  22.         moveq    #0,d3
  23.         jsr    _LVOReadArgs(a6)
  24.         move.l    d0,d1            ; ReadArgs-Error?
  25.         bne.s    .1
  26.         lea    12(sp),sp
  27.  
  28.         jsr    _LVOIoErr(a6)
  29.  
  30.         move.l    d0,d1
  31.         moveq    #0,d2
  32.         jsr    _LVOPrintFault(a6)    ; print error message
  33.  
  34.         exg    a4,a6
  35.         bra.b    exit
  36. .1:        jsr    _LVOFreeArgs(a6)
  37.         tst.l    (sp)+            ; VBR ZERO?
  38.         beq.s    .2
  39.         moveq    #1,d7            ; d7 Zero-VBR
  40.         addq.l    #4,sp
  41.         bra.s    .3
  42.  
  43. .2:        tst.l    (sp)+            ; VBR FAST?
  44.         sne    d7
  45.  
  46. .3:        tst.l    (sp)+            ; QUIET-Mode?
  47.         sne    d6
  48.  
  49.         exg    a4,a6
  50.         moveq    #0,d5
  51.         move.b    AttnFlags+1(a6),d0    ; which processor is installed?
  52.         moveq    #3,d1
  53. .4:        lsr.b    #1,d0
  54.         bcc.s    .5
  55.         add.w    #10,d5
  56.         dbf    d1,.4
  57.  
  58.         tst.b    AttnFlags+1(a6)     ; 68060?
  59.         bpl.s    .5
  60.         add.w    #20,d5
  61. .5:        sub.l    a2,a2
  62.         tst.w    d5            ; 68000? (no VBR available)
  63.         beq.s    .6
  64.         lea    getVBR(pc),a5
  65.         jsr    _LVOSupervisor(a6)    ; read VBR -> a2
  66.  
  67.         move.l    #VBR_SIZE,d2
  68.         tst.b    d7            ; change it?
  69.         beq.s    .6
  70.         bsr.s    changeVBR
  71. .6:        tst.b    d6            ; print new VBR and processor type
  72.         bne.s    exit
  73.  
  74.         exg    a4,a6
  75.         move.l    a2,-(sp)
  76.         add.l    #68000,d5
  77.         move.l    d5,-(sp)
  78.  
  79.         lea    vbr_info(pc),a0
  80.         move.l    a0,d1
  81.         move.l    sp,d2
  82.         jsr    _LVOVPrintf(a6)
  83.         addq.l    #8,sp
  84.         exg    a4,a6
  85.  
  86. exit:        move.l    a4,a1
  87.         jsr    _LVOCloseLibrary(a6)
  88.         moveq    #0,d0
  89.         rts
  90. error:        moveq    #20,d0            ; Error!
  91.         rts
  92.  
  93. changeVBR:    bmi.s    .1
  94.         move.l    a2,d0            ; copy VBR to $00000000
  95.         beq.s    .3            ; already there?
  96.         moveq    #0,d0
  97.         bra.s    .2
  98. .1:        move.l    a2,a1            ; copy VBR to FAST-Ram
  99.         jsr    _LVOTypeOfMem(a6)
  100.         btst    #MEMB_FAST,d0        ; already located in FAST-Ram?
  101.         bne.s    .3
  102.         move.l    d2,d0
  103.         moveq    #MEMF_FAST+MEMF_PUBLIC,d1
  104.         jsr    _LVOAllocMem(a6)    ; allocate Fast-Ram for VBR
  105.         tst.l    d0
  106.         beq.s    .3            ; out of memory?
  107. .2:        move.l    d0,a3
  108.         move.l    a2,a0
  109.         move.l    d0,a1
  110.         move.l    d2,d0
  111.         jsr    _LVOCopyMem(a6)
  112.         move.l    a2,-(sp)
  113.         move.l    a3,a2
  114.         lea    setVBR(pc),a5
  115.         jsr    _LVOSupervisor(a6)    ; activate new VBR
  116.         jsr    _LVOCacheClearU(a6)
  117.         move.l    (sp)+,d0
  118.         bne.s    .4
  119. .3:        rts
  120. .4:        move.l    d0,a1            ; free old VBR (except for Zero-VBRs)
  121.         move.l    d2,d0
  122.         jmp    _LVOFreeMem(a6)
  123.  
  124. getVBR:        movec    VBR,a2
  125.         rte
  126. setVBR:        movec    a2,VBR
  127.         rte
  128.  
  129. DosName:    dc.b    "dos.library",0
  130. cmd_template:    dc.b    "ZERO/S,FAST/S,QUIET/S",0
  131. vbr_info:    dc.b    "cpu: %ld  vbr: $%08lx",$a,$a,0
  132.  
  133.         end
  134.